<template>
  <el-dialog
    :visible.sync="visible"
    title="选择用户"
    width="900px"
    append-to-body
    custom-class="noPadding"
    :close-on-click-modal="false"
  >
    <ExpertList ref="expertList" pageType="dialog" />
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="submit">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import ExpertList from '@/views/expert/expert'
import { addCustomerService } from '@/api/saas/customerService';

export default {
  components: {
    ExpertList
  },
  data() {
    return {
      visible: false,
      form: {
        supportType: 0, // 0在线视频支持(专家) 1电话支持(自建联系人)
        expertIds: undefined, // 专家id,逗号分割
      },
    };
  },
  methods: {
    show() {
      this.visible = true
    },
    submit() {
      this.form.expertIds = this.$refs.expertList.ids;
      if(!this.form.expertIds.length){
        this.$message.error('请勾选需要添加的用户!')
        return
      }
      addCustomerService(this.form).then(()=>{
        this.$message.success('新增成功');
        this.visible = false;
        this.$emit('refresh')
      })
    }
  }
};
</script>
<style lang="scss" scoped>
::v-deep .noPadding .el-dialog__body{
  padding: 0;
}
</style>
